<?php

namespace app\admin\service\statistics\promotion\total;

use app\admin\service\statistics\promotion\AbstractQueryStatistician;
use app\admin\service\statistics\traits\CompletionTrait;
use app\admin\service\statistics\traits\FilterTrait;
use app\admin\service\statistics\traits\GrouperCreatedToDateTrait;
use app\common\model\Trade;


/**
 * 渠道数据 总计 退款成功订单数
 * Class RefundSuccessCount
 * @package app\admin\service\statistics\promotion\total
 */
class RefundSuccessCount extends AbstractQueryStatistician
{
    // 筛选器
    use FilterTrait;

    // 分组器
    use GrouperCreatedToDateTrait;

    // 补齐
    use CompletionTrait;

    protected function getQuery()
    {
        return Trade::field(['count(*)' => 'value'])
            ->consultingTrade()
            ->where('payStatus', Trade::PAID)
            ->where('refundStatus', Trade::REFUNDED);
    }

    protected function getDefaultValue()
    {
        return '0';
    }
}